<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text"> vs 
    <input type="text"> <button>比较谁最大》》</button> <span>？</span>
</body>
<script>
    var input=document.getElementsByTagName('input')
    var btn=document.getElementsByTagName('button')[0]
    var span=document.getElementsByTagName('span')[0]
    for(var i=0;i<input.length-1;i++){
        input[i].onkeyup=function(){
            this.value=this.value.replace(/[^\d]/,'')
        }
    }
    btn.onclick=function(){
    
        span.innerHTML=Math.max(input[0].value,input[1].value)
    }

</script>
</html>